const onEvent = function (method, state) {
  let result = {}
  let index = state.webSocket.eventList.map((eb) => eb.method).indexOf(method);
  if (state.webSocket.eventList.length > 0 && index >= 0) {
    result = Object.assign({}, state.webSocket.eventList[index]);
    state.webSocket.eventList.splice(index, 1);
  }
  return result.data;
}
const getters = {
  sidebar: state => state.app.sidebar,
  size: state => state.app.size,
  device: state => state.app.device,
  visitedViews: state => state.tagsView.visitedViews,
  cachedViews: state => state.tagsView.cachedViews,
  token: state => state.user.token,
  avatar: state => state.user.avatar,
  name: state => state.user.name,
  introduction: state => state.user.introduction,
  roleCode: state => state.user.roleCode,
  userInfo: state => state.user.userInfo,
  menus: state => state.user.menus,
  ucId: state => state.user.userInfo.ucId,
  permission_routes: state => state.permission.routes,
  errorLogs: state => state.errorLog.logs,
  alertNotice: state => onEvent('alertNotice', state),
  fireAlarm: state => onEvent('fireAlarm', state),
  refresh: state => onEvent('refresh.task.1', state),
  fireStop: state => onEvent('fireStop', state)
}
export default getters